﻿using System;

using NUnit.Framework;

using octalforty.Syndication.Core.Rss;

namespace octalforty.Syndication.UnitTests.Core.Rss
{
    /// <summary>
    /// <see cref="RssEntityBase"/> unit tests.
    /// </summary>
    public abstract class RssEntityBaseTestFixture
    {
        [Test()]
        public void RssEntityBaseDefaultValues()
        {
            RssEntityBase rssEntityBase = CreateInstance();

            Assert.IsEmpty(rssEntityBase.Categories);
            Assert.IsEmpty(rssEntityBase.Description);
            Assert.IsEmpty(rssEntityBase.Link);

            Assert.IsNotNull(rssEntityBase.PublishedOn);
            Assert.IsTrue(DateTime.Now.Subtract(rssEntityBase.PublishedOn.Value).TotalSeconds < 1);

            Assert.IsEmpty(rssEntityBase.Title);
        }

        [Test()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void TitleCannotBeNullReference()
        {
            RssEntityBase rssEntityBase = CreateInstance();
            rssEntityBase.Title = null;
        }

        [Test()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void LinkCannotBeNullReference()
        {
            RssEntityBase rssEntityBase = CreateInstance();
            rssEntityBase.Link = null;
        }

        #region Overridables
        /// <summary>
        /// When overriden in a derived class, creates an instance of <see cref="RssEntityBase"/>.
        /// </summary>
        /// <returns></returns>
        protected abstract RssEntityBase CreateInstance();
        #endregion
    }
}
